/*
Project: 		The Impact of Short-Term Employment for Low-Income Youth: Experimental 	
				Evidence from the Philippines
Authors: 		Emily A. Beam and Stella Quimbo

***********************************
Path: 			code/02_analysis
File name: 		table_a01.do 
***********************************

Purpose: 		Generates Appendix Table A1 

Inputs: 		spes_data.dta

Outputs: 		log file

Log: 				results/03_output/log_table_a01.log		

Last updated: 	22 November 2021
*/



* Column 1:  


cap log close 
log using "$output/log_table_a01.log",replace


use "$usedata_analysis/spes_data",clear 

decode _spes_tasks1,gen(taskname)

recode _spes_tasks1 -222 = 16
recode _spes_tasks2 -222 = 16

collapse (count) endline, by(_spes_tasks1 taskname)
gsort -endline
rename endline task1
rename _spes_tasks1 _spestasks
drop if missing(_spestasks)
tempfile t1
save `t1'


use "$usedata_analysis/spes_data",clear 
 tab _spes_tasks1 if _eeo_spes_privemp == 1

recode _spes_tasks1 -222 = 16
recode _spes_tasks2 -222 = 16

forval number = 1/16{
	di `number'
	gen _anytask`number' = _spes_tasks1 == `number' | _spes_tasks2 == `number'
	replace _anytask`number' = . if missing(_spes_tasks1)
}




collapse (sum) _anytask*

xpose,clear varname

replace _varname = subinstr(_varname,"_anytask","",.)

rename _varname _spestasks
destring _spestasks,replace
rename v1 anytask
merge 1:1 _spestasks using `t1'

order _spestasks task1 anytask
gsort -task1
egen rank = seq()

order rank taskname task1 anytask


outsheet using "$tables_analysis/table_a01.xls",replace


log close
exit


